package ServerConnection;

import Client.ServerInfo;
import Message.AccountSendMessageInfo;
import com.mysql.cj.xdevapi.DbDoc;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**该类是存储客户端发送的聊天记录到数据库的类*/
public class  AccountSendMessageInfoServer implements Runnable{

    private DatabaseServer databaseServer;

    AccountSendMessageInfoServer(DatabaseServer databaseServer){
        this.databaseServer=databaseServer;
    }

    public void run() {
        try {
            ServerSocket serverSocket = new ServerSocket(ServerInfo.SERVER_ACCOUNTSENDMESSAGEINFO_PORT);
            System.out.println("消息發送服务成功启动！");
            Socket socket;
            while (true) {
                socket = serverSocket.accept();
                Thread handle = new Thread(new ThreadHandleSendMessage(socket, databaseServer));
                handle.start();
            }
        } catch (IOException e) {
            System.out.println("WARNING:AccountSendMessageInfoServer Init fail,Reason:socket has ioException.");
        }
    }

}
